import Vue from 'vue'
import VueRouter from 'vue-router'
// import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

// 静态加载，初始化看到页面和框架
import Login from '@/views/login/login.vue'
import Layout from '@/layout/lay-out.vue'

// 配置路由地址和路由组件的一一对应关系
const routes = [
  // 重定向到首页home
  {
    path: '/',
    // meta:{path:'/',tltle:'后台首页'},
    redirect: '/home'
  },
  // 登录
  {
    path: '/login',
    meta:{path:'/login',title:'登录'},
    component: Login
  },
  // 首页
  {
    path: '/home',
    meta:{path:'/home',title:'后台首页'},
    component: Layout,//框架
    // 二级路由
    children:[
      {
        path:'',
        // meta:{path:'',title:'后台首页'},
        component:()=>import('@/views/home/home.vue'),

      },
    ]
  },
  // 订单管理
  {
    path:'/order',
    meta:{path:'/order',title:'订单管理'},
    component:Layout,
    children:[
      {
        path:'',
        // meta:{path:'',title:'订单管理'},
        component:()=>import('@/views/order/order.vue')
      }
    ]
  },
  // 商品管理
  {
    path:'/goods',
    component:Layout,
    meta:{path:'/goods',title:'商品管理'},
    redirect:'/goods/goods-list',
    children:[
      {
        path:'/goods/goods-list',
        meta:{path:'/goods/goods-list',title:'商品列表'},
        component:()=>import('@/views/goods/goods-list.vue')
      },
      {
        path:'/goods/goods-add',
        meta:{path:'/goods/goods-add',title:'商品添加'},
        component:()=>import('@/views/goods/goods-add.vue')
      },
      {
        path:'/goods/goods-cate',
        meta:{path:'/goods/goods-cate',title:'商品分类'},
        component:()=>import('@/views/goods/goods-cate.vue')
      },
    ]
  },
  // // 店铺管理
  {
    path: '/shop',
    meta:{path:'/shop',title:'店铺管理'},
    component: Layout,//框架
    // 二级路由
    children:[
      {
        path:'',
        // meta:{path:'',title:'店铺管理'},
        component:()=>import('@/views/shop/shop.vue'),

      },
    ]
  },
  // 账号管理
  {
    path:'/account',
    component:Layout,
    meta:{path:'/account',title:'账号管理'},
    redirect:'/account/account-list',
    children:[
      {
        path:'/account/account-add',
        meta:{path:'/account/account-add',title:'账号添加'},
        component:()=>import('@/views/account/account-add.vue')
      },
      {
        path:'/account/account-list',
        meta:{path:'/account/account-list',title:'账号列表'},
        component:()=>import('@/views/account/account-list.vue')
      },
      {
        path:'/account/account-password',
        meta:{path:'/account/account-password',title:'修改密码'},
        component:()=>import('@/views/account/account-password.vue')
      },
      {
        path:'/account/account-persion',
        meta:{path:'/account/account-persion',title:'个人中心'},
        component:()=>import('@/views/account/account-persion.vue')
      },
    ]
  },
    // 销售统计
    {
      path:'/total',
      component:Layout,
      meta:{path:'/total',title:'销售统计'},
      redirect:'/total/total-goods',
      children:[
        {
          path:'/total/total-order',
          meta:{path:'/total/total-order',title:'订单统计'},
          component:()=>import('@/views/total/total-order.vue')
        },
        {
          path:'/total/total-goods',
          meta:{path:'/total/total-goods',title:'商品统计'},
          component:()=>import('@/views/total/total-goods.vue')
        },
      ]
    },

    
]

const router = new VueRouter({
  routes
})

export default router
